<template>
  <div class="container" @click="handleGallaryClick">
    <div class="wrapper">
      <swiper :options="swiperOption">
        <swiper-slide v-for="(item,index) of imgs" :key="index">
          <img class="gallary-img" :src="item" />
        </swiper-slide>
      </swiper>
      <div class="swiper-pagination"  slot="pagination"></div>
    </div>
  </div>
</template>

<script type="text/javascript">
export default {
  name: 'CommonGallary',
  props: {
    imgs: {
      type: Array,
      default () {
        return []
      }
    }
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        paginationType: 'fraction',
        observeParents: 'true',
        observer: 'true'
      }
    }
  },
  methods: {
    handleGallaryClick () {
      this.$emit('close')
    }
  }
}
</script>

<style type="text/javastyle" lang="stylus" scoped>
@import '~styles/varibles.styl'
.container
  z-index: 99
  position: fixed
  top: 0
  right: 0
  bottom: 0
  left: 0
  background: #000
  display: flex
  flex-direction: column
  justify-content: center
  .wrapper
    background: #fff
    overflow: hidden
    height: 0
    padding-bottom: 100%
    .gallary-img
      width: 100%
      margin: auto 0
    .swiper-pagination
      width: 100%
      padding-bottom: .4rem
      position: absolute
      bottom: .4rem
      color: #fff
</style>
